package org.jfinanceobserver.persistence.jpa.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * This class is the QuotesData entity
 *
 * $Author: r78v10a07@gmail.com $ $LastChangedDate: 2013-02-14 15:47:43 +0000 (Thu, 14 Feb 2013) $ $LastChangedRevision: 34 $
 *
 * @since Feb 11, 2013
 */
@Entity
@Table(name = "QuotesData")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "QuotesData.findAll", query = "SELECT q FROM QuotesData q"),
    @NamedQuery(name = "QuotesData.findById", query = "SELECT q FROM QuotesData q WHERE q.id = :id"),
    @NamedQuery(name = "QuotesData.findByAsk", query = "SELECT q FROM QuotesData q WHERE q.ask = :ask"),
    @NamedQuery(name = "QuotesData.findByBid", query = "SELECT q FROM QuotesData q WHERE q.bid = :bid"),
    @NamedQuery(name = "QuotesData.findByChange1", query = "SELECT q FROM QuotesData q WHERE q.change1 = :change1"),
    @NamedQuery(name = "QuotesData.findByChangeInPercent", query = "SELECT q FROM QuotesData q WHERE q.changeInPercent = :changeInPercent"),
    @NamedQuery(name = "QuotesData.findByChangeRealtime", query = "SELECT q FROM QuotesData q WHERE q.changeRealtime = :changeRealtime"),
    @NamedQuery(name = "QuotesData.findByCommission", query = "SELECT q FROM QuotesData q WHERE q.commission = :commission"),
    @NamedQuery(name = "QuotesData.findByEbitda", query = "SELECT q FROM QuotesData q WHERE q.ebitda = :ebitda"),
    @NamedQuery(name = "QuotesData.findByOneyrTargetPrice", query = "SELECT q FROM QuotesData q WHERE q.oneyrTargetPrice = :oneyrTargetPrice"),
    @NamedQuery(name = "QuotesData.findByOpen", query = "SELECT q FROM QuotesData q WHERE q.open = :open"),
    @NamedQuery(name = "QuotesData.findByPEGRatio", query = "SELECT q FROM QuotesData q WHERE q.pEGRatio = :pEGRatio"),
    @NamedQuery(name = "QuotesData.findByPERatio", query = "SELECT q FROM QuotesData q WHERE q.pERatio = :pERatio"),
    @NamedQuery(name = "QuotesData.findByPriceBook", query = "SELECT q FROM QuotesData q WHERE q.priceBook = :priceBook"),
    @NamedQuery(name = "QuotesData.findByPricePaid", query = "SELECT q FROM QuotesData q WHERE q.pricePaid = :pricePaid"),
    @NamedQuery(name = "QuotesData.findByPriceSales", query = "SELECT q FROM QuotesData q WHERE q.priceSales = :priceSales"),
    @NamedQuery(name = "QuotesData.findByVolume", query = "SELECT q FROM QuotesData q WHERE q.volume = :volume"),
    @NamedQuery(name = "QuotesData.findByLoadTime", query = "SELECT q FROM QuotesData q WHERE q.loadTime = :loadTime"),
    @NamedQuery(name = "QuotesData.findByActiveId", query = "SELECT q FROM QuotesData q INNER JOIN q.activeid a WHERE a.id = :id ORDER by q.loadTime DESC"),
    @NamedQuery(name = "QuotesData.findByActiveIdandLoadTime", query = "SELECT q FROM QuotesData q INNER JOIN q.activeid a WHERE a.id = :id AND q.loadTime > :from AND q.loadTime < :to ORDER by q.loadTime DESC")})
public class QuotesData implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id")
    private Long id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Ask")
    private Float ask;
    @Column(name = "Bid")
    private Float bid;
    @Column(name = "Change1")
    private Float change1;
    @Column(name = "ChangeInPercent")
    private String changeInPercent;
    @Column(name = "ChangeRealtime")
    private Float changeRealtime;
    @Column(name = "Commission")
    private String commission;
    @Column(name = "EBITDA")
    private String ebitda;
    @Column(name = "OneyrTargetPrice")
    private Float oneyrTargetPrice;
    @Column(name = "Open")
    private Float open;
    @Column(name = "PEGRatio")
    private Float pEGRatio;
    @Column(name = "PERatio")
    private Float pERatio;
    @Column(name = "PriceBook")
    private Float priceBook;
    @Column(name = "PricePaid")
    private Float pricePaid;
    @Column(name = "PriceSales")
    private Float priceSales;
    @Column(name = "Volume")
    private Float volume;
    @Basic(optional = false)
    @Column(name = "LoadTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date loadTime;
    @JoinColumn(name = "Active_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private QuotesActive activeid;

    public QuotesData() {
    }

    public QuotesData(Long id) {
        this.id = id;
    }

    public QuotesData(Long id, Date loadTime) {
        this.id = id;
        this.loadTime = loadTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Float getAsk() {
        return ask;
    }

    public void setAsk(Float ask) {
        this.ask = ask;
    }

    public Float getBid() {
        return bid;
    }

    public void setBid(Float bid) {
        this.bid = bid;
    }

    public Float getChange1() {
        return change1;
    }

    public void setChange1(Float change1) {
        this.change1 = change1;
    }

    public String getChangeInPercent() {
        return changeInPercent;
    }

    public void setChangeInPercent(String changeInPercent) {
        this.changeInPercent = changeInPercent;
    }

    public Float getChangeRealtime() {
        return changeRealtime;
    }

    public void setChangeRealtime(Float changeRealtime) {
        this.changeRealtime = changeRealtime;
    }

    public String getCommission() {
        return commission;
    }

    public void setCommission(String commission) {
        this.commission = commission;
    }

    public String getEbitda() {
        return ebitda;
    }

    public void setEbitda(String ebitda) {
        this.ebitda = ebitda;
    }

    public Float getOneyrTargetPrice() {
        return oneyrTargetPrice;
    }

    public void setOneyrTargetPrice(Float oneyrTargetPrice) {
        this.oneyrTargetPrice = oneyrTargetPrice;
    }

    public Float getOpen() {
        return open;
    }

    public void setOpen(Float open) {
        this.open = open;
    }

    public Float getPEGRatio() {
        return pEGRatio;
    }

    public void setPEGRatio(Float pEGRatio) {
        this.pEGRatio = pEGRatio;
    }

    public Float getPERatio() {
        return pERatio;
    }

    public void setPERatio(Float pERatio) {
        this.pERatio = pERatio;
    }

    public Float getPriceBook() {
        return priceBook;
    }

    public void setPriceBook(Float priceBook) {
        this.priceBook = priceBook;
    }

    public Float getPricePaid() {
        return pricePaid;
    }

    public void setPricePaid(Float pricePaid) {
        this.pricePaid = pricePaid;
    }

    public Float getPriceSales() {
        return priceSales;
    }

    public void setPriceSales(Float priceSales) {
        this.priceSales = priceSales;
    }

    public Float getVolume() {
        return volume;
    }

    public void setVolume(Float volume) {
        this.volume = volume;
    }

    public Date getLoadTime() {
        return loadTime;
    }

    public void setLoadTime(Date loadTime) {
        this.loadTime = loadTime;
    }

    public QuotesActive getActiveid() {
        return activeid;
    }

    public void setActiveid(QuotesActive activeid) {
        this.activeid = activeid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final QuotesData other = (QuotesData) obj;
        if (!Objects.equals(this.ask, other.ask)) {
            return false;
        }
        if (!Objects.equals(this.bid, other.bid)) {
            return false;
        }
        if (!Objects.equals(this.change1, other.change1)) {
            return false;
        }
        if (!Objects.equals(this.changeInPercent, other.changeInPercent)) {
            return false;
        }
        if (!Objects.equals(this.changeRealtime, other.changeRealtime)) {
            return false;
        }
        if (!Objects.equals(this.commission, other.commission)) {
            return false;
        }
        if (!Objects.equals(this.ebitda, other.ebitda)) {
            return false;
        }
        if (!Objects.equals(this.oneyrTargetPrice, other.oneyrTargetPrice)) {
            return false;
        }
        if (!Objects.equals(this.open, other.open)) {
            return false;
        }
        if (!Objects.equals(this.pEGRatio, other.pEGRatio)) {
            return false;
        }
        if (!Objects.equals(this.pERatio, other.pERatio)) {
            return false;
        }
        if (!Objects.equals(this.priceBook, other.priceBook)) {
            return false;
        }
        if (!Objects.equals(this.pricePaid, other.pricePaid)) {
            return false;
        }
        if (!Objects.equals(this.priceSales, other.priceSales)) {
            return false;
        }
        if (!Objects.equals(this.volume, other.volume)) {
            return false;
        }
        if (!Objects.equals(this.activeid, other.activeid)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "QuotesData{" + "id=" + id + ", ask=" + ask + ", bid=" + bid + ", change1=" + change1 + ", changeInPercent=" + changeInPercent + ", changeRealtime=" + changeRealtime + ", commission=" + commission + ", ebitda=" + ebitda + ", oneyrTargetPrice=" + oneyrTargetPrice + ", open=" + open + ", pEGRatio=" + pEGRatio + ", pERatio=" + pERatio + ", priceBook=" + priceBook + ", pricePaid=" + pricePaid + ", priceSales=" + priceSales + ", volume=" + volume + ", loadTime=" + loadTime + '}';
    }
}
